# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.ods.tab.tab_end_piece_di import jms_ods__tab_end_piece_di

jms_ods__tab_end_piece = SparkSqlOperator(
    task_id='jms_ods__tab_end_piece',
    email=['rongguangfan@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_ods__tab_end_piece_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/ods/tab/tab_end_piece/execute.sql',
    pool_slots=2,
    executor_cores=2,
    executor_memory='6G',
    driver_memory='2G',
    num_executors=10,  # spark.dynamicAllocation.enabled 为 True 时，num_executors 表示最少 Executor 数
    conf={'spark.dynamicAllocation.maxExecutors': 40,
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.shuffle.service.enabled': 'true',
          'spark.sql.shuffle.partitions': 200
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions.pernode': 20,
              'hive.exec.max.dynamic.partitions': 20
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=40),
)

jms_ods__tab_end_piece << jms_ods__tab_end_piece_di